cmake_minimum_required(VERSION 3.3 FATAL_ERROR)

project(ImageMap)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)


# qt

set(Qt5_DIR "/Users/dai/Qt/5.15.2/clang_64/lib/cmake/Qt5")

if(NOT DEFINED VTK_QT_VERSION)
    set(VTK_QT_VERSION 5)
endif()
set(qt_components Core Gui Widgets Network)
list(SORT qt_components)
# We have ui files, so this will also bring in the macro:
#   qt5_wrap_ui or qt_wrap_ui from Widgets.
find_package(Qt${VTK_QT_VERSION} QUIET
        REQUIRED COMPONENTS ${qt_components}
        )

foreach(_qt_comp IN LISTS qt_components)
    list(APPEND qt_modules "Qt${VTK_QT_VERSION}::${_qt_comp}")
endforeach()



set(VTK_DIR "/Users/dai/Qt/5.15.2/clang_64/lib/cmake/Qt5/lib/cmake/vtk-9.0")

find_package(VTK COMPONENTS
        vtkCommonColor
        vtkCommonCore
        vtkIOImage
        vtkImagingColor
        vtkImagingCore
        vtkImagingGeneral
        vtkInteractionImage
        vtkInteractionStyle
        vtkRenderingContextOpenGL2
        vtkRenderingCore
        vtkRenderingFreeType
        vtkRenderingGL2PSOpenGL2
        vtkRenderingOpenGL2
        vtkFiltersSources
        vtkInteractionStyle
        vtkInteractionWidgets
        vtkRenderingAnnotation
        vtkRenderingContextOpenGL2
        vtkRenderingCore
        vtkRenderingFreeType
        QUIET
        )

if (NOT VTK_FOUND)
    message("Skipping ImageMap: ${VTK_NOT_FOUND_MESSAGE}")
    return ()
endif()
message (STATUS "VTK_VERSION: ${VTK_VERSION}")


# include all components
add_executable(ImageMap MACOSX_BUNDLE ImageMap.cxx DownloadManager.h DownloadManager.cpp)
target_link_libraries(ImageMap PRIVATE ${VTK_LIBRARIES}  ${qt_modules})
# vtk_module_autoinit is needed
vtk_module_autoinit(
        TARGETS ImageMap
        MODULES ${VTK_LIBRARIES}
)
